#ifndef GS_VALUE_H
#define GS_VALUE_H

#include "include/IValue.h"

namespace Gs
{
	class String;
	class Object;
	class Managed;
	class Function;

	// Represents a GorillaScript value.
	class Value : public IValue
	{
	private:
		ValueType _type;
		union
		{
			int _i;
			float _f;
			String *_s;
			Object *_o;
			Function *_fn;
			Managed *_m;
			UserPointer _p;
		};

	public:
		// Initialises a new instance of the Value class.
		Value();

		// Gets the type of the value.
		ValueType GetType() const;

		// Gets the type name of the value's type.
		const char *GetTypeName() const;

		// Gets the value as an integer, converting if necessary.
		int ToInt() const;

		// Gets the value as a float, converting if necessary.
		float ToFloat() const;

		// Gets the value as a string, converting if necessary.
		IString *ToString(IContext *context) const;

		// Gets the value as an object.
		IObject *ToObject() const;

		// Gets the value as a user pointer.
		UserPointer ToUserPointer() const;

		// Gets the value as a native function.
		NativeFunction ToNativeFunction() const;

		// Gets the value as a function.
		Function *ToFunction() const;

		// Sets the value to a nil value.
		void Set();

		// Sets the value to an integer.
		void Set(int i);

		// Sets the value to a float.
		void Set(float f);

		// Sets the value to a string.
		void Set(String *s);

		// Sets the value to an object.
		void Set(Object *o);

		// Sets the value to a function.
		void Set(Function *f);

		// Sets the value to a pointer.
		void Set(UserPointer p);

		// Sets the value to another value.
		void Set(Value *v);
	};
}

#endif